<?php

declare(strict_types=1);
/**
 * This file is part of Sws.
 *
 * @link     https://gitee.com/sreeb/sws-dev.git
 * @document https://gitee.com/sreeb/sws-dev.git
 * @contact  https://gitee.com/sreeb/sws-dev.git
 * @license  https://gitee.com/sreeb/sws-dev/blob/master/LICENSE
 */
namespace app\middleware;

class TestMiddleware
{
    /**
     * 中间件类.
     * @param $request
     * @param $next
     * @return mixed
     */
    public function handle($request, $next)
    {
        $token = mt_rand(1, 2) == 1;
        if (! $token) {
            return 'Invalid token.';
        }
        return $next($request);
    }
}
